package cn.iocoder.yudao.module.fengdong.smartelderly.dal.mysql.activity;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.fengdong.smartelderly.dal.dataobject.activity.ActivityDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin.activity.vo.*;

/**
 * 活动管理 Mapper
 *
 * @author 沣东养老院管理员
 */
@Mapper
public interface ActivityMapper extends BaseMapperX<ActivityDO> {

    default PageResult<ActivityDO> selectPage(ActivityPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ActivityDO>()
                .eqIfPresent(ActivityDO::getTitle, reqVO.getTitle())
                .eqIfPresent(ActivityDO::getImageUrls, reqVO.getImageUrls())
                .eqIfPresent(ActivityDO::getDetail, reqVO.getDetail())
                .betweenIfPresent(ActivityDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(ActivityDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(ActivityDO::getPreviewNum, reqVO.getPreviewNum())
                .eqIfPresent(ActivityDO::getAstrictNum, reqVO.getAstrictNum())
                .eqIfPresent(ActivityDO::getNowNum, reqVO.getNowNum())
                .betweenIfPresent(ActivityDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ActivityDO::getType, reqVO.getType())
                .eqIfPresent(ActivityDO::getKind, reqVO.getKind())
                .orderByDesc(ActivityDO::getCreateTime));
    }

    default List<ActivityDO> selectList(ActivityExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ActivityDO>()
                .eqIfPresent(ActivityDO::getTitle, reqVO.getTitle())
                .eqIfPresent(ActivityDO::getImageUrls, reqVO.getImageUrls())
                .eqIfPresent(ActivityDO::getDetail, reqVO.getDetail())
                .betweenIfPresent(ActivityDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(ActivityDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(ActivityDO::getPreviewNum, reqVO.getPreviewNum())
                .eqIfPresent(ActivityDO::getAstrictNum, reqVO.getAstrictNum())
                .eqIfPresent(ActivityDO::getNowNum, reqVO.getNowNum())
                .betweenIfPresent(ActivityDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ActivityDO::getType, reqVO.getType())
                .eqIfPresent(ActivityDO::getKind, reqVO.getKind())
                .orderByDesc(ActivityDO::getId));
    }

}
